<?php

if (!function_exists('array_combine')) {
	function array_combine($a1,$a2)
	{
		for($i=0;$i<count($a1);$i++)
			$ra[$a1[$i]] = $a2[$i];
		if(isset($ra)) return $ra; else return false;
	}
}

if (!function_exists('htmlspecialchars_decode')) {
	function htmlspecialchars_decode($text)
	{
		return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
	}
}

class shizukiSharedFunctions extends NucleusPlugin
{

	const PLUGINNAME = 'constTest';

	function pluginCheck($pluginName)
	{
		global $manager;
		if (!$manager->pluginInstalled('NP_' . $pluginName)) {
			return false;
		}
		$plugin =& $manager->getPlugin('NP_' . $pluginName);
		return $plugin;
	}

	function includeLanguageFile()
	{
		$language = ereg_replace( '[\\|/]', '', getLanguageName());
		if (file_exists($this->getDirectory() . 'language/' . $language . '.php')) {
			include_once($this->getDirectory() . 'language/' . $language . '.php');
		} else {
			include_once($this->getDirectory() . 'language/english.php');
		}
	}

	function nucleusVersionCheck()
	{
		$ver_min = (getNucleusVersion() < $this->getMinNucleusVersion());
		$pat_min = ((getNucleusVersion() == $this->getMinNucleusVersion()) &&
					(getNucleusPatchLevel() < $this->getMinNucleusPatchLevel()));
		if ($ver_min || $pat_min) {
			global $DIR_LIBS;
			// uninstall plugin again...
			include_once($DIR_LIBS . 'ADMIN.php');
			$admin = new ADMIN();
			$admin->deleteOnePlugin($this->getID());
		
			// ...and show error
			$admin->error(_ERROR_NUCLEUSVERSIONREQ .
			$this->getMinNucleusVersion() . ' patch ' .
			$this->getMinNucleusPatchLevel());
		}
	}

	function _hsc($str)
	{
		return htmlspecialchars($str, ENT_QUOTES, _CHARSET);
	}

	function _deHsc($str)
	{
		return htmlspecialchars_decode($str, ENT_QUOTES, _CHARSET);
	}

	function supportsFeature($what)
	{
		switch($what){
			case 'SqlTablePrefix':
				return 1;
			case 'HelpPage':
				return (int)(file_exists($this->getDirectory() . 'help.html'));
			default:
				return 0;
		}
	}

	function hasAdminArea()
	{
		return (int)(file_exists($this->getDirectory() . 'index.php'));
	}

	function getDescription(){
		$pluginName = $this->getShortName();
		if (defined('NP' . strtoupper($pluginName) . '_DESC')) {
			return constant('NP' . strtoupper($pluginName) . '_DESC');
		} else {
			return $this->getName();
		}
	}

	function getURL()
	{
		return 'http://japan.nucleuscms.org/wiki/plugins:' . $this->getShortName();
	}

	function getAuthor()
	{
		return 'shizuki';
	}

	function getMinNucleusVersion()
	{
		return '330';
	}

	function getName()
	{
		$pluginName = $this->getShortName();
		if (defined('NP' . strtoupper($pluginName) . '_NAME')) {
			return constant('NP' . strtoupper($pluginName) . '_NAME');
		} else {
			return get_class($this);
		}
	}










}



